import {
  WebMapTileServiceImageryProvider,
  Rectangle
} from '@cesiumjs';

export default {
  webTileImagery() {
    return {
      name: "webTileImagery",
      title: "webTileImagery",
      create(options) {
        let {
          url,
          format,
          layer,
          style,
          tileMatrixSetID,
          tileMatrixLabels,
          clock,
          times,
          dimensions,
          tileWidth,
          tileHeight,
          tilingScheme,
          rectangle,
          minimumLevel,
          maximumLevel,
          ellipsoid,
          credit,
          subdomains,
        } = options;
        if (!url) return null;
        format = format||'image/jpeg';
        rectangle = rectangle||Rectangle.MAX_VALUE;
        const provider = new WebMapTileServiceImageryProvider({
          url,
          format,
          layer,
          style,
          tileMatrixSetID,
          tileMatrixLabels,
          clock,
          times,
          dimensions,
          tileWidth,
          tileHeight,
          tilingScheme,
          rectangle,
          minimumLevel,
          maximumLevel,
          ellipsoid,
          credit,
          subdomains,

        })
        return provider
      }
    }
  },
}
